Feature: Census Page - Get Census Info

  # Author: Maria Chen
  # Execution&Update History
  # |Date          |Owner        |Update/Execution Remark        |Comments                          |
  # |4/8/2016    |Maria Chen   |First Draft                    |
  ##################################Test Case That will success############################################
  @happy
  Scenario: All the info is valid - Validate zip code
    When I send a GET request to "census/census-condition?allianceId=Gro21010&zipCode=98001&productLine=ifp"
    Then the response status should be 200
    And the ifpSep should be correct
    And the JSON response should be
      """
      {
      "maxPrimaryAge": 130,
      "minPrimaryAge": 0,
      "maxSpouseAge": 130,
      "minSpouseAge": 14,
      "maxChildAge": 26,
      "ifpSep": "${json-unit.ignore}",
      "conditionForFamilyType": {},
      "states": [
      {
      "state": "Washington",
      "stateAbbr": "WA",
      "county": "KING"
      }
      ],
      "counties": [
      "KING"
      ]
      }
      """

  @happy
  Scenario: All the info is valid - Validate zip code
    When I send a GET request to "census/census-condition?allianceId=CAR27748&zipCode=20904&productLine=ifp"
    Then the response status should be 200
    And the ifpSep should be correct
    And the JSON response should be
      """
      {
      "maxPrimaryAge": 130,
      "minPrimaryAge": 0,
      "maxSpouseAge": 130,
      "minSpouseAge": 14,
      "maxChildAge": 25,
      "ifpSep": "${json-unit.ignore}",
      "conditionForFamilyType": {},
      "states": [
      {
      "state": "Maryland",
      "stateAbbr": "MD",
      "county": "MONTGOMERY"
      },
      {
      "state": "Maryland",
      "stateAbbr": "MD",
      "county": "PRINCE GEORGES"
      }
      ],
      "counties": [
      "MONTGOMERY",
      "PRINCE GEORGES"
      ]
      }
      """

  ##################################Test Case That will fail############################################
  @sad
  Scenario Outline: Alliance Id Validation
    When I send a GET request to "census/census-condition?allianceId=<allianceId>&zipCode=98001&productLine=ifp"
    Then the response status should be 400
    And the error message should be "Enter a valid allianceId"
    And the error type should be "PARAMETER_INVALID"

    Examples: 
      | allianceId |
      #AllianceId empty
      |            |
      #Alliance Id doesn't belong to istore
      | jet90000   |
      #Alliance Id doesn't exist
      | dsdsdd     |

  @sad
  Scenario Outline: Zip code Validation
    When I send a GET request to "census/census-condition?allianceId=Gro21010&zipCode=<zipcode>&productLine=ifp"
    Then the response status should be 400
    And the error message should be "Enter a valid zip code"
    And the error type should be "PARAMETER_INVALID"

    Examples: 
      | zipcode |
      #Zip code empty
      |         |
      #Zip code doesn't exist
      | 88888   |
      #Zip code invalid
      | 88ddd   |

  @sad
  Scenario Outline: Product line Validation
    When I send a GET request to "census/census-condition?allianceId=Gro21010&zipCode=98001&productLine=<productline>"
    Then the response status should be 400
    And the error message should be "Enter a valid productline"
    And the error type should be "PARAMETER_INVALID"

    Examples: 
      | productline |
      #Product line empty
      |             |
      #Product line doesn't exist
      | medicare    |
